package com.urfresh.sp.flume.configure;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerDocumentationConfig {

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //API列表对应的title
                .title("URFresh埋点")
                //API列表对应的描述
                .description("URFresh埋点系统API接口列表:")
                .license("URFresh")
                .termsOfServiceUrl("api")
                .version("1.0.0")
                //API负责人
                .contact(new Contact("weiyu.zhang","", "weiyu.zhang@urfresh.cn"))
                .build();
    }

    @Bean
    public Docket customImplementation(){
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                //basePackage需对应到Controller包的路径
                .apis(RequestHandlerSelectors.basePackage("com.urfresh.sp.flume"))
                .build()
                .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
                .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
                .apiInfo(apiInfo());
    }
}
